// JavaScript Document
// calls php page for variable value, brings in an "=" sign separated string

//	END GLOBAL VARIABLES


document.addEventListener("deviceready",onDeviceReady,false);
function onDeviceReady() {
	navigator.splashscreen.hide();	
}

$.get('http://143.88.103.50:20000/appTrend/AppTrend.aspx', function (data)
{
	// string is separated into an array
	// breaking up data(string)=date~FL1~FL2(strings associated with columns) each string then converted into array
	var splitColumns = data.split("~");
	var i;
	var tempData;
	
	for(i=0; i<pageDataElements.length; i++)
	{
		tempData = splitColumns[i].split("=");
		
		document.getElementById(pageDateElements[i]).innerHTML = tempData[0];
		document.getElementById(pageDataElements[i]).innerHTML = tempData[1];
		
		if (tempData[2] > 0) 
		{
			document.getElementById(pageTrendElements[i]).className="icon-fixed-width icon-circle-arrow-up  upgG";	//icon-2x
		}
		else if(tempData[2] == 0)
		{
			document.getElementById(pageTrendElements[i]).className="icon-fixed-width icon-minus-sign  upgB";
		}
		else if(tempData[2] < 0)
		{
			document.getElementById(pageTrendElements[i]).className="icon-fixed-width icon-circle-arrow-down  upgR";
		}
	}
	
	
}
)
// checks connection, displays warnings	
.error(function() 
{
	
	for(i=0; i<pageDataElements.length; i++)
	{
		
		document.getElementById(pageDateElements[i]).innerHTML = "Check your internet connection!";
		
		document.getElementById(pageTrendElements[i]).className="icon-fixed-width icon-remove-sign  upgError";
		
	}
		
		
}// End connection check	
);


// 	GLOBAL VARIABLES

var pageDataElements = new Array("data_0", "data_1", "data_2", "data_3", "data_4", "data_5", "data_6", "data_7", "data_8", "data_9", "data_10", "data_11", "data_12",
						"data_13", "data_14", "data_15", "data_16", "data_17", "data_18", "data_19", "data_20", "data_21", "data_22", "data_23", "data_24",
						"data_25", "data_26", "data_27", "data_28", "data_29", "data_30", "data_31", "data_32", "data_33", "data_34", "data_35", "data_36",
						"data_37", "data_38", "data_39", "data_40", "data_41", "data_42", "data_43", "data_44", "data_45", "data_46", "data_47", "data_48",
						"data_49", "data_50", "data_51", "data_52", "data_53", "data_54", "data_55", "data_56", "data_57", "data_58", "data_59", "data_60");
						
var pageDateElements = new Array("date_0", "date_1", "date_2", "date_3", "date_4", "date_5", "date_6", "date_7", "date_8", "date_9", "date_10", "date_11", "date_12",
						"date_13", "date_14", "date_15", "date_16", "date_17", "date_18", "date_19", "date_20", "date_21", "date_22", "date_23", "date_24",
						"date_25", "date_26", "date_27", "date_28", "date_29", "date_30", "date_31", "date_32", "date_33", "date_34", "date_35", "date_36",
						"date_37", "date_38", "date_39", "date_40", "date_41", "date_42", "date_43", "date_44", "date_45", "date_46", "date_47", "date_48",
						"date_49", "date_50", "date_51", "date_52", "date_53", "date_54", "date_55", "date_56", "date_57", "date_58", "date_59", "date_60");
						
var pageTrendElements = new Array("trend0", "trend1", "trend2", "trend3", "trend4", "trend5", "trend6", "trend7", "trend8", "trend9", "trend10", "trend11", "trend12",
						"trend13", "trend14", "trend15", "trend16", "trend17", "trend18", "trend19", "trend20", "trend21", "trend22", "trend23", "trend24",
						"trend25", "trend26", "trend27", "trend28", "trend29", "trend30", "trend31", "trend32", "trend33", "trend34", "trend35", "trend36",
						"trend37", "trend38", "trend39", "trend40", "trend41", "trend42", "trend43", "trend44", "trend45", "trend46", "trend47", "trend48",
						"trend49", "trend50", "trend51", "trend52", "trend53", "trend54", "trend55", "trend56", "trend57", "trend58", "trend59", "trend60");
